<html>
<head><meta charset="utf-8"><title>where is `tcx.symbol_name()` implemented? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html">where is `tcx.symbol_name()` implemented?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212784205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212784205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sfzhu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212784205">(Oct 09 2020 at 05:09)</a>:</h4>
<p>I found the following code in <code>rustc_middle/src/mir/mono.rs</code>.</p>
<div class="codehilite"><pre><span></span><code>    pub fn symbol_name(&amp;self, tcx: TyCtxt&lt;&#39;tcx&gt;) -&gt; SymbolName&lt;&#39;tcx&gt; {
        match *self {
            MonoItem::Fn(instance) =&gt; tcx.symbol_name(instance),
            MonoItem::Static(def_id) =&gt; tcx.symbol_name(Instance::mono(tcx, def_id)),
            MonoItem::GlobalAsm(hir_id) =&gt; {
                let def_id = tcx.hir().local_def_id(hir_id);
                SymbolName::new(tcx, &amp;format!(&quot;global_asm_{:?}&quot;, def_id))
            }
        }
    }
</code></pre></div>


<p>But I couldln't find where <code>tcx.symbol_name(...)</code> is implemented. I couldn't find it with a JetBrain IDE with rust plugin nor by grepping the source code with "fn symbol_name".</p>



<a name="212784257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212784257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212784257">(Oct 09 2020 at 05:10)</a>:</h4>
<p>It's probably a query</p>



<a name="212784263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212784263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212784263">(Oct 09 2020 at 05:11)</a>:</h4>
<p>Try searching for <code>query symbol_name</code></p>



<a name="212784347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212784347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212784347">(Oct 09 2020 at 05:13)</a>:</h4>
<blockquote>
<p>I couldn't find it with a jetbrains ide</p>
</blockquote>
<p>Yeah I'm not surprised lol, queries are generated by a proc macro that generates macro_rules macros that generate other macros</p>



<a name="212784919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212784919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sfzhu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212784919">(Oct 09 2020 at 05:28)</a>:</h4>
<p>Yeah, it may also fail at finding FFI related things...</p>



<a name="212790038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212790038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212790038">(Oct 09 2020 at 07:13)</a>:</h4>
<p>(deleted)</p>



<a name="212790066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212790066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212790066">(Oct 09 2020 at 07:13)</a>:</h4>
<p>(deleted)</p>



<a name="212790111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/where%20is%20%60tcx.symbol_name%28%29%60%20implemented%3F/near/212790111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Haris Muzaffar <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F.html#212790111">(Oct 09 2020 at 07:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="230287">Stu</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/where.20is.20.60tcx.2Esymbol_name().60.20implemented.3F/near/212790038">said</a>:</p>
<blockquote>
<p>In the first snippet, the immutable reference is not used after the mutable reference, so it gets dropped before the mutable reference is created. There’s a name for this kind of feature but i don’t know it.</p>
</blockquote>
<p>i moved this to a separate topic, could you please move the reply too</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>